package com.heima.thread;

import com.alibaba.fastjson.JSON;
import com.heima.vo.PatientVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.yaml.snakeyaml.events.Event;

import java.util.List;

public class CacheThread implements Runnable{

    private RedisTemplate<String,String> redisTemplate;

    private Integer userId;
    private List<PatientVo> voList;
    public CacheThread( RedisTemplate<String,String> redisTemplate , Integer userId, List<PatientVo> voList){
        this.redisTemplate=redisTemplate;
        this.userId= userId;
        this.voList=voList;
    }
    @Override
    public void run() {

        redisTemplate.opsForValue().set("patientList:user_" + userId, JSON.toJSONString(voList));
    }
}
